package com.tjrac.generalpermissions.filter;

import com.tjrac.filter.aspect.ProxyControl;
import com.tjrac.filter.stereotype.ParameterFilter;
import com.tjrac.filter.stereotype.PermissionControl;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * PermissionControl 权限控制
 *
 * @author : xziying
 * @create : 2020-11-15 17:59
 */
@Aspect
@Component
public class ProxyControlImpl extends ProxyControl {

    /**
     * 设置切点
     */
    @Pointcut("execution(public * com.tjrac.generalpermissions.service..*.*(..))")
    public void proxyControlService() {}


    @Override
    @Around(value = "proxyControlService() && @annotation(permissionControl)")
    public Object permissionControl(ProceedingJoinPoint pjp, PermissionControl permissionControl) throws Throwable {
        return super.permissionControl(pjp, permissionControl);
    }

    @Override
    @Around(value = "proxyControlService() && @annotation(parameterFilter)")
    public Object parameterFilter(ProceedingJoinPoint pjp, ParameterFilter parameterFilter) throws Throwable {
        return super.parameterFilter(pjp, parameterFilter);
    }
}
